.row
  .col-md-12
    .card
      .card-header
        h3.card-title = t("admin.settings.#{@setting.var}")
        .card-tools
          a href="#{admin_settings_path}"
            i.icon.far.fa-list-alt
            = t('links.back_to_list')

      = simple_form_for(@setting, url: admin_setting_path(@setting.var), method: :patch) do |f|
        .card-body
          - if @setting.errors.size > 0
            .callout.callout-danger
              h5 = t('activerecord.errors.models.setting.default_message', key: t("admin.settings.#{@setting.var}"))
              ul.mb-0
                - @setting.errors.each do |error|
                  li = error.message

          input.hidden type="hidden" value="#{@setting.type}" name="setting[type]"
          - if @setting.type == :boolean
            = f.input :value, label: t('admin.settings.enable'), as: :boolean, hint: false
          - elsif @setting.type == :hash || @setting.type == :array
            = f.input :value, as: :text, input_html: { value: JSON.pretty_generate(@value) }
          - elsif @setting.inclusion?
            = f.input :value, as: :radio_buttons, collection: @setting.inclusion_values, checked: @value, hint: false
          - else
            = f.input :value, as: :text, input_html: { value: @value }, hint: false

          - unless @setting.field_validates.empty?
            small.form-text.text-muted
              = t('admin.settings.validates', value: @setting.field_validates.join(' / '))
        .card-footer
          - if @setting.persisted?
            .float-right
              = link_to t('admin.settings.reset'), admin_setting_path(@setting.var), class: 'btn btn-danger', \
                data: { turbo_method: :delete, turbo_confirm: t('channels.messages.confirm.destroy') }

          .float-left
            = f.button :submit
